<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
            <title>Cindy JS</title>
            <script type="text/javascript" src="../build/js/Cindy.js"></script>
            <link rel="stylesheet" href="../css/cindy.css">


            </head>

	<body style="font-family:Arial;">

        <h1>CindyJS: L-System</h1>


        <script id='csmove' type='text/x-cindyscript'>
            draw(A);
            list(x):=(
                      gsave();
                      translate((0,-7));
                      repeat(length(x),turtle(x_#));
                      grestore();
                      );

            turtle(x):=(
                        (if(x=="F",foreward()));
                        (if(x=="R",foreward()));
                        (if(x=="L",foreward()));
                        (if(x=="+",left()));
                        (if(x=="-",right()));
                        (if(x=="[",open()));
                        (if(x=="]",close()));
                        (if(x==">",rect()));

                        );

            foreward():=(
                         draw((0,0),(l,0));
                         translate((l,0))
                         );
            left():=rotate(angle);
            right():=rotate(-angle);
            rect():=rotate(90°);
            open():=gsave();
            close():=grestore();

            l=.2;
            angle=(A.x+7)/5;
            word=">F";
            repl=[["F","F+F--F+F"]];
            word="L";

            repl=[["L","L+R++R-L--LL-R+"], ["R","-L+RR++R+L--L-R"]];
            repeat(4,
                   word=replace(word,repl);
                   );

            list(word);
            errc(word);



        </script>

        <div  id="CSCanvas" style="width:600px; height:600px; border:2px solid #000000"></div>

        <script type="text/javascript">

            var gslp=[
                      {name:"A", kind:"P", type:"Free", pos:[-7,2,1]},
                                            ];


            CindyJS({canvasname:"CSCanvas",
                        movescript:"csmove",
                        geometry:gslp});





            </script>





	</body>
</html>
